class Solution:
    def maxProduct(self, words) -> int:
        code = [set() for _ in range(26)]
        a = ord('a')
        conflicted = [[i == j for j in range(len(words))] for i in range(len(words))]
        allLen = [len(words[i]) for i in range(len(words))]
        for wordIndex in range(len(words)):
            for w in words[wordIndex]:
                nowSet = code[ord(w) - a]
                if wordIndex in nowSet:
                    continue
                for nowIndex in nowSet:
                    conflicted[wordIndex][nowIndex] = True
                    conflicted[nowIndex][wordIndex] = True
                nowSet.add(wordIndex)

        maxLen = 0
        for i in range(len(conflicted)):
            for j in range(len(conflicted[i])):
                if conflicted[i][j]:
                    continue
                nowLen = allLen[i]*allLen[j]
                maxLen = max(nowLen, maxLen)
        return maxLen

if __name__ == '__main__':
    so = Solution()
    # words = ["a","aa","aaa","aaaa"]
    words = ["ffdeeabbccfaaeebfccaddcbd","ddfcfbaf","ffcdefefacdfbfdc","fa","fecfde","efcedddafebcbbfaae","efafbf","ecbcbed","aaec","bdedcbfafccaafcfefeffdc","ffdac","cbefdffbbed","dfaefdccaddaacbaca","eda","beedefdddafeedaffcafcabbe","dbabfefaabdecbff","adcccdcefaefdddd","dafcdaebaafdeabcfeacbbbf","eadeebfbcdacaabe","cceaa","dfbdccfecafbdeacbddaedf","addbabd","aaaaacfc","cddaacabfefbfcffecacaa","ebcfeaf","ecffcffbcadeefbabaccafda","bbcbffefaeaccedeb","dcfabedbffbcdceacbcecdedf","afbdebcbccfcfac","eadcabedbcafadbefa","fefeaddbcecaed","fdeaacbcebacebadaeb","ccddfafcbaffbeedfa","edbc","cabefdafe","dadedfbabbfcbfeabcea","feabba","ddbdeeefcbdde","acecdbeceabbdcee","edf","bbdcffdadfabefaddadd","bcdbbedebafcfffeeca","bceebbcffdabbee","edcbfeabfbaeadea","efabbcaafcbca","badcbfcecedbebbdaaaeddf","cbbcfabbfdfebddcfffcbeebacf","fbbfcdbdbeacdeeabb","aaae","adfefeb","efcafdcaedebbc","befcaeadefafdcec","dddb","ecccbbdceeecd","def","debdfddeeaddfdddabccabfe","dbcabccedecadb","bfbde","ddddaeeacdeedcafbfabbc","dbbefcfcbfcfbdccacffdaafd","dcdcebfbefccebbaebafbdaffda","ddeefdefdccedceecfcfbdeeeda","acfcadcafcc","eebeadacbeccedfffc","fcaacdeaaca","cecaebfcfbfeefcdbbfabdbcf","ffcffdd","babcbe","abbfefaedfddeba","fafafceeabcaefaddcccd","bf","bbceecebf","bdfbfbfbeffbdeccb","fcafdded","afafecfcfecfd","dcbebcfbafdaebbaaaae","ecbceeecccfc","eecffefc","dedaffdcacbccadedafefebdb","afabaaacdbefffbe","faf","dfeccfefcbbbec","cabddbdefddeafdb","fcbbabfabccefcebeefaecdb","afbdfd","ffafaadafeaabaadabb","caffbddcafddbfcdfb","dadaacfeaaebeda","faedabdfafcafa","fdcefefc","afbfdadeaeeddceddeebeaaeac","eeddeabaadbacddffedfbccdbed","aecdbfeae","eddaabaabfeacbefbbdecdc","aabcfefba","ebaaedce","faabcafcfebdcccfcd","daefbbeccbebacffc","fecffce","dedfcdebdeaddacaceabdccacec","afeacaaffbebcefbcfeefefa","caeaecbcb","eabadbbde","fcdddeabc","ceaa","babbabeebebcaafacec","bddfeedadefbbfbcecdc","dadfeddfbb","fefcacffdcabbdedafc","eeaafabebbeadf","cbefdcfbdd","bffbdaddfbecfedcabd","fdaa","cbdcddfcaddebbac","dfdfcaccefbbbedecabdaf","aecaae","cebebbafdfe","aebedfafafcbfcacfdace","aaeffe","adbbeaeabe","abbdcdaebeedddfcce","edafcaeecdbec","effabfcccbccefbfcefdc","faecfcddff","ddffcdaefc","ffcbbdffcadfccedceaadbda","bdcccefcbeafcdfa","fcfcfabcb","bfbacfbeeee","becfbfcbbbbacafecdfabafcff","eadfeffe","ef","caebbdedeccfcaaddcabadad","feb","aaaeeaebcbfbbcaccddfccde","bafaadcdbbcffefbcecf","baacc","dffcbdbdaef","aeffdbeebbeeeabcedefadefcea","bcbdffd","baaedcbceafbccebbebbeeeaffc","afbbeafedffcfbafbcb","bcbcbbdfcca","cacaaafdeee","eadcefdddddcd","daaddaaeebeefbcec","cedcfbdcdcadbb","aafcfe","edeaa","bffadeddccaacdcaa","acadbccfefab","dcffaecdaebeecccdacdbde","afdcccefaf","eeacebdcbdbcccb","faaecacaeceebcb","ebcaeffdffacffabbabccefaa","cbcdcadefdabbdcdafba","cdadfacadafeabcecdacbaaccc","dab","ffaeffaccfefacfdafbaccbf","fbcefcdbfabdbdabac","cdfccfdef","cedcfeaedddababdffdbabf","cbdacdffcc","bcfdc","edfcbaecdbabcbcaecdc","edadfcfadefcddbf","dbedfdcdccbddaccaffabbdd","deabbccdaaddf","eeadc","aefccfebeecabdfbda","dccfcdacafebecbefebdfdebf","fabbebdbaff","bfdfbddaeeeaacfeca","bafdfdfae","fecfaadffbcfdabfac","abcaaeefbbefcadeaceadffeb","aaafdeefbfccafeaedaea","ebafdfbcdfdddbbeedbfecbbcfb","edfbeccdcaccf","bbdceffbeabcafae","eeadaaedd","aeecbfecdeeadafded","fbdbdbfadbcab","dcdaadabfbb","fccdcfffefbcdb","dfbfcae","beedccaafbadcacadfd","bcfbdbfdcbfd","aafedacbabfeddedaadcb","acfdbfaccbcbac","bfeaaaafcaeddaffccebacbbff","fbdcacacbabddebdeecccba","cdededefebaedb","abeadffbacee","aadabfddcaeadefdfefba","edffcdd","acceeaeacacaa","cbeafbafccdbbdfbfccbe","eeebbfceacbfdddfebf","cd","bebfbfcc","dccfffcedaafbcbaccec","facefddfaafaafddfcbdaf","caedfcfbbede","fdfcdaebefdaacbf","deccabcfeabfebccfaafbe","ea","dbbabdcf","adeaaaefcbffdccbf","deacacddcbfeadcefdccbd","ccebddbebacbecafcdaceeadbd","decafccaaf","cecbabcbffbfac","effeeafbdbdfdcaaedbfadbaaba","fcffccabafdafbdbbf","fcaea","eab","cbcbcdbfdfcfeaacfd","bebcdbbaeaccaebfaafac","fdfdcebbadbba","bb","ababebaadadebc","aeacecacffedfceeacdde","feacdbcefbeaeddcdccdebee","fafadacdedeebdafedccc","dbffaedaebeaedbccfc","ebdaabeefbaaa","bacaaeebfaaeaabccbbfa","cebacdbdaeeeddaacdefdbdc","cfbbdf","ffdbcdcfcdbfcebaaecbdfdbac","ecdacadfdcbcdcdedbfaf","cffcaeccac","acceacbdfbedfddefeaedf","fdbfdebcbfbeddefaaedfabcea","ddaafbcfdadfbeacbcf","dafa","efbefeebddbaefafbed","dffeff","ffcedbb","fefbeb","aedffaebe","dfdcfeeedaaecceebbabfcafeab","bddcfedacfda","dafdfeeebbdbbefbcceddbdfcdc","dbdaaeddbafaeeeabdcbeafbfb","dcbdfeabadcffebb","cecbaccecfcbe","fddfedbdadacdaadbdfeba","bddebcfdbaeec","cfaaabc","eddbcbccab","fafffecdcacedacacbcefddcfc","fccbabfdeefceb","cacddeceafeacdffffdccfddac","dcdfbdacdbbadebbcdc","dabde","dbacaeca","beefdbcc","cedbbebbfabdbdbbba","badedaadbbfacfafcedec","fcdcabddcdaceddeaababebc","efafbcfbeafaecee","addcbafad","efbdacbbf","bbabbbcfaaffdbfcf","abecfeaadaedff","fe","adfdfffdedbabfeffbffcbdfdbe","edccafdadecbabdcfcfadd","ddaddcedbbadccbfaebf","fdcaaddaf","fcdcbddebbecdbfce","dfaecbbfccbbfddbfbfadfecbf","defcdefbaffdcfdddaebed","cadecbaecacefabcdea","bcbdaebbdebbcdb","dddd","bcfecafefcbfacdecfc","fbefeefa","ffcacbd","ffafebf","dbfaddfadcfcdeddcebe","babbcefcb","aebfcddcdefadb","baecddabbdecefdefdfc","bebe","ebbbfbcabfccbcacaccbcab","ecffedefbbdccfdafbaddf","bdbbbecfafb","bfaeedcadcbdbddcbcaaeffbccd","dbdcdffbb","caee","ccfcabecdaee","abbecaeefc","cdbfbcfbfeddcbcbadbceabede","adddfddcebdcebdb","cbfff","cafafbcabbbcedd","fedcebffdadfbcedbd","fedbedcdbabbbcdadd","fdfeddeaefadcffadadaf","abaebbbaebebfa","dcdbfdedad","afdaebcdccfaadefdbeaddcabed","bccbceffcdfefbcbd","efeeecefdcbdabcb","cdc","cddadccadefbaccdcbfffedaa","dacbcddabeddbbcaebdeca","eccfaddaa","daabba","eceafbcadfdebfceda","abddbaebeccacfdefbacdc","cdcfdaeccdcfaadfdfdecba","eacaffbdaabe","acdbecfebbdbbebaaab","faebacdafcecafbecca","ccedcefaabfaa","ecaebdb","deeaeafbddfdafcfcd","ef","fceab","cdbceecbbfbebadcddbcbfb","cccafeecedbddfadedddadf","abfbccafbcbddfcdaaeefffa","dcdbdcdfbaffdcaafebddadf","bdaaecccbdeccabbdaafcc","addfeeedbeacffdcbfaadbdb","effcbbeaaebeefbaeec","adfcaa","ebceffbaefbadfbfcefa","aaefbaedddcdbbfabb","aeadcfeaddabbffefdcadc","ddbcfede","cfeffaecb","cddedebabefe","ecdb","aafddabfdadacafdfbbaba","dfcadfaeddafafc","daecbfbfaecfafadeacdedafdd","baef","afdfefdcacceaeebbeebd","faa","da","dbddbfbdcaeececfcccdfa","acff","fdfafca","ebbdebfffdcfdecffcbe","bacbdfe","afebcaceebaf","deafafaafdaadddaacaacccb","acdbaefabe","aaeafdbbabbcdceda","adfbafbdbcafbcb","aabccc","ddcadc","aedcbdfcccdccabbabbaadf","dbcfcdacad","aacaceadafbdafaccfaaceb","bbcdebdea","bfaeedbacbabedefbfcadedcecd","dccf","caafbcabafffec","cfcbebacbdcbabafdeeebcffda","dbfcffcbadcfcacdcdbccfdfa","bdc","dadcfeaeaeeebcbd","bffcbfdebccedb","cccdceebfcfdacacdca","aceddacdbfd","aefdafcfccfbc","cdba","deaaeacabdcabffecbdacedeae","ccdbeaefbcad","ebfbaddaeeceedeacafd","adabdefefaadaacabdcebfd","cdddccadacbeeebceecb","ededea","cdfe","afeafcefc","ebddbcfebfefceffcc","edcab","abacacdbfcfcfdaaceeca","dbaffc","dabeddddbbbaaebb","adcbecfdbbfe","baacbbbfddacbabdaefecfc","daadbafbaebe","bedbbaaedcdafcfaabbbee","dacbea","ecbffbfb","cdcbadbfacb","fbceeccaffadeecddbdbee","acafbedfccdfb","dabdbfdeeeabdaafbafbecc","bcfddddcbbbaebbaee","bcaecbeafdeafdeadfbccf","bebafeaddfedfcdbabcbeba","fabeaafacdfcfcccacdfbadad","eebdefbdacfbabcfeeffcfeeffa","feeefdbaddccfdbcfc","dafbbaccbefabfefdea","fefdfebaaefbffcd","eabcafbceebadaafe","adbedea","cdacfcccaeaadcbcefcf","cfeacbdcceabaeedded","bc","ccbcdbaca","abffcac","eefadddfcebeaffdadcedbcbede","aebacddeaedefdebeac","efcacefcf","aaebdbffd","fffbdefadfabdeafbbabfbaabf","dfddceaebfc","ecbcabf","deacadfbcffdcfaecacabcecf","ccaabeaacba","eaaabf","eaabdfeaadbedbdbbbeec","eddeceddfaeecbcbcefaaec","eafeacecddafaeefedabdddbfea","eda","dbeeeeabbbfbdceed","eab","caddafbbe","efcafcfecbbfdebeeedde","cbeeffadfbbfa","bffadcbccf","dfacafacceaabebbaeb","bbadbceffffbafafdbaacebce","daedaaacbfbdbbeaeeddbedbdc","fcbbd","bbeffdddfee","acaeacf","aaabdedabcadafebcdeac","ddbeabddbaeefadfcafbe","bcabcbccdcefdacccfdbaebee","dfebcefc","eeeeecfbccbf","bde","bdedfebfccbedfbbeadaffdbaa","ebacbaaaafbcdcbbdbcdaec","cbeede","fda","cddfcf","ffcaefdd","aadbaaacbabb","aefacadaaccbdebbef","beedaaeccddfbdadbfafdbedaf","dcfafcfdbfceefff","dbcdf","edfecd","bcdac","fceda","edefbeabafcacc","bcafeccb","dccffb","afdd","ccbaecfe","ebddebaaacfe","cfffacdebdb","dedbabcfb","feefaadabd","cbadfadabbecdda","dfe","beabcbeefcdbceaaececaccbed","eae","afaeaffbaecfcbfbdb","bccbbddfbeea","adccfeddaebddbcbedaddbdbccb","ddabaeaacbcddabbaaaefcc","cbe","dcfbffbcebeedad","adfadccabfabfadc","fdfbaaaabccbffcfaebbcfcc","efbcac","aafdbbfbdabaebaa","eefccdaabebfbaceeadebcacb","bfeeecafefbdeeaadfbdfae","fafbefbceacaeecdcddafbb","dd","bcbbaabdfdaeb","ceedacfaddf","cfabefcfeaeaecbeeabdfbcadb","bfcfcafebcffbcf","fbcdaddcacecbdbbdefdbadfaad","eafdecedbafaadafbdf","bbedffcedcaffdcbfdeeabdbf","dcc","eeeeaffebbef","bfaddbbcbefbcaaebfd","bdd","cceecfbab","ebacdfebafcf","cab","beeedffa"]
    r = so.maxProduct(words)
    print(r)
